package edu.zju.gis.dbfg.fileserver.service.impl;

import com.github.pagehelper.PageHelper;
import edu.zju.gis.dbfg.common.Page;
import edu.zju.gis.dbfg.common.base.BaseServiceImpl;
import edu.zju.gis.dbfg.fileserver.mapper.LoaderMonitorMapper;
import edu.zju.gis.dbfg.fileserver.model.LoaderMonitor;
import edu.zju.gis.dbfg.fileserver.model.vo.MonitorInfo;
import edu.zju.gis.dbfg.fileserver.service.LoaderMonitorService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoaderMonitorServiceImpl extends BaseServiceImpl<LoaderMonitorMapper, LoaderMonitor, String> implements LoaderMonitorService {
    public List<MonitorInfo> selectAll(String userId) {
        return mapper.selectAll(userId);
    }



    public LoaderMonitor selectByName(String name) {
        return mapper.selectByName(name);
    }

    public Page<MonitorInfo> selectByPage(String userId, Page page) {
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new Page<>(mapper.selectAll(userId));
    }
    public Page<MonitorInfo> selectByPageFinish(String userId, Page page) {
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new Page<>(mapper.selectAllFinish(userId));
    }

    public LoaderMonitor watchStatus(String id) {
//        LoaderMonitor loaderMonitor=mapper.watchStatus(id);
//        return new MonitorInfo(loaderMonitor);
        return mapper.watchStatus(id);
    }

    @Override
    public LoaderMonitor select(String id) {
        return mapper.selectByPrimaryKey(id);
    }

    public  int deleteByPrimaryKey(String id){
        return  mapper.deleteByPrimaryKey(id);
    }
}
